//
//  UIButton+Extension.swift
//  TYHWeibo
//
//  Created by IOS on 15/8/5.
//  Copyright © 2015年 IOS. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(title: String, fontSize: CGFloat = 12, coler: UIColor = UIColor.darkGrayColor(),backColor: UIColor = UIColor.whiteColor()) {
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(coler, forState: UIControlState.Normal)
        backgroundColor = backColor
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        
    }
    
    convenience init(title: String, imageName: String, fontSize: CGFloat = 12, coler: UIColor = UIColor.darkGrayColor()) {
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitleColor(coler, forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
    
    convenience init(imageName: String) {
        self.init()
        setImage(imageName)
        
    }
    
    func setImage(imageName: String) {
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
    }
    
}